﻿<UserControl
  x:Class="AdventureWorksApp.LoginUI.LoginStatus" 
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
  xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d">

    <StackPanel x:Name="LayoutRoot" Style="{StaticResource LoginStatusStyle}">
        <vsm:VisualStateManager.VisualStateGroups>
            <vsm:VisualStateGroup x:Name="loginStates">
                <vsm:VisualState x:Name="windowsAuth">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginControls" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.0000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="logoutControls" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.0000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="loggedIn">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="loginControls" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.0000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
                <vsm:VisualState x:Name="loggedOut">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="welcomeControls" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.0000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="logoutControls" Storyboard.TargetProperty="(UIElement.Visibility)">
                            <DiscreteObjectKeyFrame KeyTime="00:00:00.0000000">
                                <DiscreteObjectKeyFrame.Value>
                                    <Visibility>Collapsed</Visibility>
                                </DiscreteObjectKeyFrame.Value>
                            </DiscreteObjectKeyFrame>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </vsm:VisualState>
            </vsm:VisualStateGroup>
        </vsm:VisualStateManager.VisualStateGroups>

        <StackPanel x:Name="loginControls" Style="{StaticResource LoginPanelStyle}">
            <Button x:Name="loginButton" Style="{StaticResource LoginRegisterLinkStyle}"
                    Content="{Binding Path=Strings.LoginButton, Source={StaticResource ApplicationResources}}" 
                    Click="LoginButton_Click" />
        </StackPanel>

        <StackPanel x:Name="welcomeControls" Style="{StaticResource LoginPanelStyle}">
            <TextBlock x:Name="welcomeText" Style="{StaticResource WelcomeTextStyle}"/>
        </StackPanel>

        <StackPanel x:Name="logoutControls" Style="{StaticResource LoginPanelStyle}">
            <TextBlock Text="  |  " Style="{StaticResource SpacerStyle}"/>
            <Button x:Name="logoutButton" Style="{StaticResource LoginRegisterLinkStyle}"
                    Content="{Binding Path=Strings.LogOffButton, Source={StaticResource ApplicationResources}}" 
                    IsEnabled="{Binding Path=Authentication.IsLoggingOut, Converter={StaticResource NotOperatorValueConverter}}"
                    Click="LogoutButton_Click" />
        </StackPanel>
    </StackPanel>

</UserControl>